import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 666
 * Date: 2023-04-11
 * Time: 15:22
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            if(n==0){

                return;
            }
            if (n <= 1) {
                System.out.println(0);
                return;
            }
            int a=0;
            while (n>2) {
                int m = 0;
                m = n / 3;
                a+=m;
                n%=3;
n+=m;
            }
            if (a % 3 == 2) {
                System.out.println(a + 1);
            } else
                System.out.println(a);
        }
    }
}
